package com.czz.portal.controller;

import com.czz.common.vo.R;
import com.czz.portal.entity.Category;
import com.czz.portal.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName: CategoryController
 * @Author Czz
 * @Date 2020/2/8
 * @Time 11:11
 **/
@RestController
@RequestMapping(value = "/category")
public class CategoryController {

    @Autowired
    CategoryService categoryService;

    /**
     * @Description 获取所有一级分类列表
     * @Param []
     * @Return com.czz.common.vo.R
     * @Author Czz
     * @Date 2020/2/8
     * @Time 11:09
     **/
    @GetMapping(value = "/parent")
    public R getParentCategoryList(){
        List<Category> parentCategoryList = categoryService.getParentCategoryList();
        return R.ok().data("items",parentCategoryList);
    }

    /**
     * @Description 获取所有二级分类列表
     * @Param []
     * @Return com.czz.common.vo.R
     * @Author Czz
     * @Date 2020/2/8
     * @Time 11:10
     **/
    @GetMapping(value = "")
    public R getCategoryList(){
        List<Category> categoryList = categoryService.getCategoryList();
        return R.ok().data("items",categoryList);
    }
}
